//
//  PreviewClubPictureViewController.m
//  The_Month_Club
//
//  Created by BaoBaoDaRen on 16/10/4.
//  Copyright © 2016年 康振超. All rights reserved.
//

#import "PreviewClubPictureViewController.h"
#import "zoomCellView.h"

@interface PreviewClubPictureViewController ()<UIAlertViewDelegate, UIActionSheetDelegate>

@property (nonatomic, strong) UIButton * sharePicBtn;
@property (nonatomic, strong) UIButton * collectPicBtn;
@property (nonatomic, strong) UIButton * deletePicBtn;
@property (nonatomic, strong) zoomCellView * zooView;
@property (nonatomic, strong) UIAlertView * deletePicAlert;

@end

@implementation PreviewClubPictureViewController

-(void)showTextViewNavViewTo1{
    NSMutableArray * showTextViewNavViewNameArrTo1 = [NSMutableArray new];
    UIView * showTextViewNavViewViewTo1 = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 0, 0)];
    showTextViewNavViewViewTo1.clipsToBounds = YES;
       UILabel * oldshowSSSSTip = [[UILabel alloc]init];
    oldshowSSSSTip.clipsToBounds = YES;
    oldshowSSSSTip.text = @"kass显示区";
    oldshowSSSSTip.textColor = ColorHex(@"#f0f0f0");
    oldshowSSSSTip.textAlignment = NSTextAlignmentCenter;
    oldshowSSSSTip.font = [UIFont systemFontOfSize:28];
    oldshowSSSSTip.hidden = YES;
    [self.view addSubview:oldshowSSSSTip];
    [self.view addSubview:showTextViewNavViewViewTo1];
    UILabel * showTextViewNavViewLabelTo1 = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 100, 100)];
    NSInteger showTextViewNavViewNumberTo1 = arc4random_uniform(20);
    NSLog(@"：%ld", (long)showTextViewNavViewNumberTo1);
    showTextViewNavViewLabelTo1.text = [NSString stringWithFormat:@"%ld",(long)showTextViewNavViewNumberTo1];
    [showTextViewNavViewLabelTo1 addSubview:showTextViewNavViewLabelTo1];
    
    UIImageView * showTextViewNavViewLabelTo2 = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 100, 100)];
    [showTextViewNavViewViewTo1 addSubview:showTextViewNavViewLabelTo2];
    
}
- (void)showOldAddNavViewToMainOldView1{
    UIView * oldBgSS = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 0, 0)];
    oldBgSS.clipsToBounds = YES;
       UILabel * oldshowSSSSTip = [[UILabel alloc]init];
    oldshowSSSSTip.clipsToBounds = YES;
    oldshowSSSSTip.text = @"kass显示区";
    oldshowSSSSTip.textColor = ColorHex(@"#f0f0f0");
    oldshowSSSSTip.textAlignment = NSTextAlignmentCenter;
    oldshowSSSSTip.font = [UIFont systemFontOfSize:28];
    oldshowSSSSTip.hidden = YES;
    [self.view addSubview:oldshowSSSSTip];
    [self.view addSubview:oldBgSS];
    
    UIButton * sendBtn = [[UIButton alloc]initWithFrame:CGRectMake(KScreen_W-75, kStatusBarHeight+10, 60, 46)];
    sendBtn.layer.cornerRadius = 3;
    sendBtn.backgroundColor = [UIColor whiteColor];
    [sendBtn setTitle:@"发送" forState:UIControlStateNormal];
    [sendBtn setTitleColor:ColorHex(@"#333333") forState:UIControlStateNormal];
    sendBtn.titleLabel.font = [UIFont systemFontOfSize:16];
    [sendBtn addTarget:self action:@selector(sendTap) forControlEvents:UIControlEventTouchUpInside];
    [oldBgSS addSubview:sendBtn];
    
    UIView * sendBg = [[UIView alloc]initWithFrame:CGRectMake(15, kStatusBarHeight+66, KScreen_W-30, (KScreen_H-KSafeAreaBottomHeight-25-(kStatusBarHeight+66))/2)];
    sendBg.backgroundColor = [UIColor whiteColor];
    sendBg.layer.cornerRadius = 3;
    [oldBgSS addSubview:sendBg];
    
    UILabel * sendTip = [[UILabel alloc]initWithFrame:CGRectMake(0, (sendBg.frame.size.height-40)/2, sendBg.frame.size.width, 40)];
    sendTip.text = @"发送区";
    sendTip.textColor = ColorHex(@"#f0f0f0");
    sendTip.textAlignment = NSTextAlignmentCenter;
    sendTip.font = [UIFont systemFontOfSize:28];
    [sendBg addSubview:sendTip];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.navigationController.navigationBar.hidden = YES;
    
    self.automaticallyAdjustsScrollViewInsets = NO;
    self.view.backgroundColor = [UIColor blackColor];
    self.title = NSLocalizedString(@"预览", nil);
    [self.navigationController.navigationBar setTitleTextAttributes:[NSDictionary dictionaryWithObject:[UIColor whiteColor] forKey:NSForegroundColorAttributeName]];
    self.navigationController.navigationBar.barTintColor = [UIColor whiteColor];
    
    showNavBar = NO;
    
    // zoomCellView上添加的一个旋转了-90度的tableView，需要添加按钮或者控制直接在zoomCellView上添加...
    self.zooView = [[zoomCellView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height) imageSize:CGSizeZero];
       UILabel * oldshowSSSSTip = [[UILabel alloc]init];
    oldshowSSSSTip.clipsToBounds = YES;
    oldshowSSSSTip.text = @"kass显示区";
    oldshowSSSSTip.textColor = ColorHex(@"#f0f0f0");
    oldshowSSSSTip.textAlignment = NSTextAlignmentCenter;
    oldshowSSSSTip.font = [UIFont systemFontOfSize:28];
    oldshowSSSSTip.hidden = YES;
    [self.view addSubview:oldshowSSSSTip];
    [self.view addSubview:self.zooView];

    [self.zooView updateImageDate:self.imageArray selectIndex:self.beginIndex];

    UITapGestureRecognizer * doubleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(doubleTapped)];
    [doubleTap setNumberOfTapsRequired:2];
    [self.view addGestureRecognizer:doubleTap];
    
//    BasicNavigationBarView * customNavBar = [[BasicNavigationBarView alloc] initWithFrame:CGRectMake(0, 0, KScreen_W, NavBar_H + StatusBar_H)];
//    customNavBar.delegate = self;
//    [customNavBar setNavigationBarWith:@"预览" andBGColor:[UIColor whiteColor] andTitleColor:GBlackColor andImage:@"nav_left_back" andHidLine:YES];
//
       UILabel * oldshowSSSSTip2 = [[UILabel alloc]init];
    oldshowSSSSTip2.clipsToBounds = YES;
    oldshowSSSSTip2.text = @"kass显示区";
    oldshowSSSSTip2.textColor = ColorHex(@"#f0f0f0");
    oldshowSSSSTip2.textAlignment = NSTextAlignmentCenter;
    oldshowSSSSTip2.font = [UIFont systemFontOfSize:28];
    oldshowSSSSTip2.hidden = YES;
    [self.view addSubview:oldshowSSSSTip2];
//    [self.view addSubview:customNavBar];

}

#pragma mark - BasicNavigationBarViewDelegate
- (void)customNavgationBarDidClicked
{
    [self.navigationController popViewControllerAnimated:YES];
}

#pragma mark - 将图片保存到相册
- (void)saveSickDocImageToPhotos:(UIImage*)savedImage
{
    UIImageWriteToSavedPhotosAlbum(savedImage, self, @selector(image:didFinishSavingWithError:contextInfo:), NULL);
}

// 指定回调方法
- (void)image:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo
{
    NSString *msg = nil ;
    if (error != NULL) {
        msg = NSLocalizedString(@"保存图片失败", nil);
    } else {
        msg = NSLocalizedString(@"保存图片成功", nil);
    }
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"提示", nil) message:msg delegate:nil cancelButtonTitle:NSLocalizedString(@"确定", nil) otherButtonTitles:nil, nil];
    [alert show];
}

- (void)doubleTapped
{
    
}

- (void)preViewViewDidTapped
{
    if (!showNavBar)
    {
        showNavBar = YES;
        self.navigationController.navigationBar.hidden = NO;
        
        if (!_hidEditView)
        {
            self.previewEditView.hidden = NO;
        } else
        {
            self.previewEditView.hidden = YES;
        }
    } else
    {
        showNavBar = NO;
        self.navigationController.navigationBar.hidden = YES;
        if (!_hidEditView)
        {
            self.previewEditView.hidden = YES;
        } else
        {
            self.previewEditView.hidden = YES;
        }
    }
}

- (void)leftButtonDidClicked:(UIButton *)sender
{
    [self dismissViewControllerAnimated:YES completion:nil];
}

- (void)dealloc
{
    [[NSNotificationCenter defaultCenter] removeObserver:self];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
